﻿@using CNKI.TPI.Web.Base
<script type="text/javascript">
    $(function ($) {

        function G(s) {
            return document.getElementById(s);
        }

        function getStyle(obj, attr) {
            if (obj.currentStyle) {
                return obj.currentStyle[attr];
            } else {
                return getComputedStyle(obj, false)[attr];
            }
        }

        function Animate(obj, json) {
            if (obj.timer) {
                clearInterval(obj.timer);
            }
            obj.timer = setInterval(function () {
                for (var attr in json) {
                    var iCur = parseInt(getStyle(obj, attr));
                    iCur = iCur ? iCur : 0;
                    var iSpeed = (json[attr] - iCur) / 5;
                    iSpeed = iSpeed > 0 ? Math.ceil(iSpeed) : Math.floor(iSpeed);
                    obj.style[attr] = iCur + iSpeed + 'px';
                    if (iCur == json[attr]) {
                        clearInterval(obj.timer);
                    }
                }
            }, 30);
        }

        var oPic = G("picBox");
        var oList = G("listBox");

        var oPrev = G("prev1");
        var oNext = G("next1");
        var oPrevTop = G("prevTop");
        var oNextTop = G("nextTop");

        var oPicLi = oPic.getElementsByTagName("li");
        var oListLi = oList.getElementsByTagName("li");
        var len1 = oPicLi.length;
        var len2 = oListLi.length;

        var oPicUl = oPic.getElementsByTagName("ul")[0];
        var oListUl = oList.getElementsByTagName("ul")[0];
        var w1 = oPicLi[0].offsetWidth;
        var w2 = oListLi[0].offsetWidth;

        oPicUl.style.width = w1 * len1 + "px";
        oListUl.style.width = w2 * len2 + "px";

        var index = 0;

        var num = 4;
        var num2 = Math.ceil(num / 2);

        function Change() {

            Animate(oPicUl, { left: -index * w1 });

            if (index < num2) {
                Animate(oListUl, { left: 0 });
            } else if (index + num2 <= len2) {
                Animate(oListUl, { left: -(index - num2 + 1) * w2 });
            } else {
                Animate(oListUl, { left: -(len2 - num) * w2 });
            }

            for (var i = 0; i < len2; i++) {
                oListLi[i].className = "";
                if (i == index) {
                    oListLi[i].className = "on";
                }
            }
        }

        oNextTop.onclick = oNext.onclick = function () {
            index++;
            index = index == len2 ? 0 : index;
            Change();
        }

        oPrevTop.onclick = oPrev.onclick = function () {
            index--;
            index = index == -1 ? len2 - 1 : index;
            Change();
        }

        for (var i = 0; i < len2; i++) {
            oListLi[i].index = i;
            oListLi[i].onclick = function () {
                index = this.index;
                Change();
            }
        }

    })
</script>
<!--面包屑一-->
<div class="crumbLink">
    @*<a href="Home">首页</a>&gt;<a href="javascript:void(0);">检索</a>&gt;期刊*@

</div>
@if (ViewBag.DetialField != null && @ViewBag.DetialField.Rows.Count > 0)
{
    <h2 class='doc-title'>@Html.Raw(ColumnAliasHelper.GetContent(ViewBag.DetialField, 0, 0))</h2>
    <div class="doc-value">
        @{
            string view = ColumnAliasHelper.GetContent(ViewBag.DetialField, @ViewBag.DbName, 0, "SYS_FLD_BROWSERATE");
            string download = ColumnAliasHelper.GetContent(ViewBag.DetialField, @ViewBag.DbName, 0, "SYS_FLD_DOWNLOADRATE");
        }
        浏览量：@Html.Raw(@view == "" ? "0" : @view)
        下载量：@Html.Raw(@download == "" ? "0" : @download)
        @{ int type = (int)MediaType.Pic;
            if (SessionHelper.HasDownloadRight(ViewBag.dbId))
            {

                if (ViewBag.FileCount != null && ViewBag.FileCount > 1)
                {
                    <a onclick="showdown()" class='btn btn-m btn-prim-f ml10'><i class="iconfont icon-download"></i>下载</a>
                }
                else
                {
                    <a onclick="javascript:isDown(@ViewBag.dbId, @ViewBag.recordId,@type, '@Html.Raw(Url.Action("IsShowDown", "File"))','-1','@ViewBag.DownType')" class='btn btn-m btn-prim-f ml10'>
                        <i class="iconfont icon-download"></i>下载
                    </a>
                }
            }
        }
        @if (SessionHelper.GetUserInfo() != null
                && ((ConfigHelper.IsAnonymousControlEnabled() && SessionHelper.GetUserInfo().UserCode.ToUpper() != ConfigHelper.GetAnonymousAccount().ToUpper())
                || !ConfigHelper.IsAnonymousControlEnabled()))
        {
            <span class="favCate">
                <a onclick="showFavCate('@ColumnAliasHelper.GetContent(ViewBag.DetialField, 0, 0)')" class='btn btn-m btn-prim-f ml10'><i class="iconfont icon-star"></i>收藏</a>
            </span>
        }
    </div>
    @* “图片下载”弹层 *@
            <div class="talkDiv Down" style="left: 30%;top:30%; display: none;">
                <div class="talkDiv-title" style="height: 40px; line-height: 40px; padding-left: 10px; font-size: 16px; position: relative; border-bottom: 1px solid #DADADA; background-color: #efefef; font-family: 微软雅黑">
                    <span>下载</span>
                    <a class="icon icon-close" title="关闭" href="javascript:void(0);" onclick="closedown()" style="top: 0px"><i class="iconfont icon-error3"></i></a>
                </div>
                <div class="talkDiv-body" style="padding-top: 25px">
                    <ul class="video-download">
                        @if (ViewBag.FileInfoAll != null)
                        {
                            foreach (CNKI.TPI.Web.Search.Model.METADATA_FILE m in ViewBag.FileInfoAll)
                            {

                                <li>
                                    @m.FILENAME
                                <a class="btn btn-m btn-prim-f posa" style="margin-right:40px"
                                   onclick="javascript:isDown(@ViewBag.dbId, @ViewBag.recordId,@type, '@Html.Raw(Url.Action("IsShowDown", "File"))','@m.SYSID','@ViewBag.DownType')">点击下载</a>
                            </li>
                            }
                        }

                    </ul>
                </div>
            </div>

            <div class="doc-con clearfix video-con" style="height:400px">
                @*//内容*@
                <div class='video-con-r'>
                    <div class="video-con-r-in">
                        <P></P>
                        @foreach (System.Data.DataRow dr in ViewBag.DetialField.Rows)
                {
                    int i = 0;
                    System.Data.DataRow columnInfo = null;
                    foreach (System.Data.DataColumn column in ViewBag.DetialField.Columns)
                    {
                        if (column.ColumnName.StartsWith("SYS_FLD_") || column.ColumnName == "浏览量" || i == 0)
                        {
                            i++;
                            continue;
                        }
                        columnInfo = ViewBag.RColumnInfo.Select(string.Format("Name='{0}'", column.ColumnName))[0];
                        string colname = column.ColumnName;
                        if (!string.IsNullOrEmpty(columnInfo["DispName"].ToString()))
                        {
                            colname = columnInfo["DispName"].ToString();
                        }
                        if (!string.IsNullOrEmpty(dr[column.ColumnName].ToString()))
                        {
                                    <p>@colname：@Html.Raw(dr[column.ColumnName].ToString())</p>
                                }
                            }
                        }
                    </div>
                </div>
                @*//图片*@

                <div class="mod18 video-con-l video-con-l1">
                    <div class="directionBtn">
                        <a id="prev1" class="direction-btn prev"></a>
                        <a id="next1" class="direction-btn next"></a>
                    </div>
                    <span id="prevTop" class="direction-btn prev"></span>
                    <span id="nextTop" class="direction-btn next"></span>
                    <div id="picBox" class="picBox">
                        <ul class="cf">
                            @if (ViewBag.FileInfo != null)
                            {
                                int i = 1;
                                foreach (CNKI.TPI.Web.Search.Model.METADATA_FILE item in ViewBag.FileInfo)
                                {
                                    <li>
                                        <a name="@i" href="@ResourceHelper.GetDigitalPicURL((int)@ViewBag.DbID, @item.SYSID)" target="_blank">
                                            <img width="600" height="340" src="@ResourceHelper.GetDigitalPicURL((int)@ViewBag.DbID, @item.SYSID)" alt="" />
                                        </a>
                                    </li>
                                }

                            }

                        </ul>
                    </div>
                    <div class="listBoxP">
                        <div id="listBox" class="listBox">
                            <ul class="cf">
                                @if (ViewBag.FileInfo != null)
                                {
                                    foreach (CNKI.TPI.Web.Search.Model.METADATA_FILE item in ViewBag.FileInfo)
                                    {
                                        <li>
                                            <i class="arr2"></i>
                                            <img width="72" height="54" src="@ResourceHelper.GetSmallPicURL((int)@ViewBag.DbID, @item.SYSID)" />
                                        </li>
                                    }
                                }
                            </ul>
                        </div>
                    </div>
                </div>

            </div>

            }
